<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    const person = {
        name: 'jack',
        age: 18,
        language: ['js','css']
    }
    console.log(Object.keys(person))
    console.log(Object.values(person))
    console.log(Object.entries(person))

    //声明对象的简写
    //如果对象的属性key和属性的值value相同，name可以将value省略
    const name = '张三'
    const age = '22'
    const person1 = {
        name,
        age
    }
    console.log(person1)
    let person2 = {
        name: 'jack',
        eat: function (food) {
            console.log(this.name + "在吃" + food)
        },
        //箭头函数不能喝this一起使用
        // eat2: (food) => console.log(this.name+"在吃"+food)
        eat2: (food) => console.log(person2.name+"在吃"+food),
        eat3(food){
            console.log(this.name+"在吃"+food)
        }
    }
    person2.eat("香蕉")
    person2.eat2("苹果")
    person2.eat3("栗子")


    //对象的扩展运算符
    let person3 = {
        name: 'lucy',
        age: '19'
    }
    let copyPerson = {...person3}
    console.log(copyPerson)

    let age1 = {age: 15}
    let name1 = {name: 'amy'}
    let person4 = {...age1, ...name1}
    console.log(person4)

</script>
</body>
</html>